package com.example.spring.boot.rabbitmq.listener;

import com.example.spring.boot.rabbitmq.constant.DelayExchangeConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * <p>
 * 延迟队列监听
 * </p>
 *
 * @author weixin
 * @date 2023/3/28 15:06
 */
@Slf4j
@Component
public class DelayQueueListener {

    @RabbitListener(queues = DelayExchangeConstant.DELAY_QUEUE)
    public void receiveDelayMessage(String message) {
        log.info("DelayQueueListener.receiveMessage,  delay dead letter message: {}, timestamp: {}",
                message,
                LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyy-MM-dd HH:mm:ss"))
        );
    }

}
